/**
 * 
 */
package ar.edu.unq.svnpermission.ui.pages;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.CompoundPropertyModel;
import ar.edu.unq.svnpermission.ui.model.UseCase;

/**
 * Representa una plantilla para la construccion de WebPage
 * @author nicolas
 * @param <T>
 */
public abstract class PageTemplate<E extends UseCase> extends WebPage
{

	private Form<E> form;
	
	public PageTemplate()
	{
		this.setForm(new Form<E>(this.getFormName(),this.createModel()));
		this.add(this.getForm());
		this.buildPage();
	}
	
	/**
	 * Se encarga de construir la pagina.
	 * @author nicolas
	 */
	public void buildPage()
	{
		this.addFields();
		this.addButtons();
	}
	
	public Form<E> getForm() {
		return form;
	}

	public void  setForm(Form<E> form) {
		this.form = form;
	}		
	
	protected abstract void addFields();
	protected abstract void addButtons();
	protected abstract CompoundPropertyModel<E> createModel();
	protected abstract String getFormName();
	
	
}
